<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="sync">同步获取信息</div>
    <div id="async">异步获取信息...</div>
    <script>
      const xhr = new XMLHttpRequest();
      xhr.open("GET", "http://127.0.0.1:8081/tours");
      xhr.onload = function () {
        console.log(xhr.getResponseHeader("content-type"));
        console.log(xhr.getAllResponseHeaders()); //head
        // console.log(xhr.response); //body
      };
      xhr.send();
      sync.innerHTML = "this is sync";
    </script>
  </body>
</html>
